/**
 * 获取用户的openid存储、删除等
*/
import storage from '@/util/localstorage/index.js'

let store_openid_key = "storeopenidkey"

export default {
	getMyopenid() {
		let val = storage.getStorage(store_openid_key)
		if (val) {
			let nowTimes = new Date().getTime()
			if (nowTimes - val.expiretime > 0) {
				//过期
				return ''
			}
			return val.openid
		}
		return ''
	},
	setMyopenid(openid) {
		let dic = {
			openid: openid,
			expiretime: (new Date().getTime()) + 3 * 24 * 3600000 //过期时间为3天
		}
		storage.setStorage({
			key: store_openid_key,
			jsonstr: dic
		})
	},
	delMyopenid() {
		storage.removeStorage(store_openid_key)
	}
}
